const express = require('express');
const path = require('path');

const app = express();
app.listen(3000, () => {
    console.log('服务器已开启');
})

const myquery = require('./myquery');

app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, 'shopping.html'));
})

app.get('/shopping', async (req, res) => {
    let [err, reslut] = await myquery('select * from trade');
    if (err) {
        res.send({ code: 400, msg: err })
    }
    res.send({ code: 200, msg: '渲染成功', data: reslut });
})